<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>登陆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        a {
            text-decoration: none;
            display: block;
            height: 22px;
            background: orangered;
            color: #ffffff;
            margin: 30px 0;
            width: 50px;
            text-align: center;
        }
    </style>
</head>
<body>

<form id="login" role="form" action="/register" method="post">
    <div class="form-group">
        <label for="name">账户</label>
        <input type="text" class="form-control" name="userName" id="name"
               placeholder="账户" autofocus>
    </div>

    <div class="form-group">
        <label  for="password">密码</label>
        <div>
            <input type="password" id="password" name="password" minlength="6" maxlength="12">
        </div>
    </div>
    <p>如若还未注册请点击注册</p>
    <button type="submit" class="btn btn-default">登陆</button>
    <div class="btn btn-default" onclick="window.location.href='/login'">注册</div>
</form>
<a href="/">主页</a>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script>
    // $('#login').on('submit', function (e) {
    //     e.preventDefault()
    //     var formdata = $(this).serialize()
    //     console.log(formdata)
    //     $.ajax({
    //         url: '/login',
    //         type: 'post',
    //         data: formdata,
    //         dataType: 'json',
    //         success: function (data) {
    //             var err_code = data.err_code
    //             if (err_code === 0) {
    //                 window.alert('登陆成功')
    //                 window.location.href = '/'
    //             } else if (err_code === 1) {
    //                 window.alert('密码错误')
    //             } else if (err_code === 2) {
    //                 window.alert('账户不存在')
    //             } else {
    //                 window.alert('服务器错误')
    //             }
    //         }
    //     })
    // })

</script>
</body>
</html>
